import { Component } from 'react'
import ReactDOM from 'react-dom'


class App extends Component {
  // constructor() {
  //   super()
  //   this.state = {
  //     msg: 'Hello',
  //     count: 10
  //   }
  // }
  state = {
    msg: 'Hello',
    count: 10
  }
  render() {
    return <div>
      <h1>我是根组件</h1>
      <div>{this.state.msg}</div>
      <div>{this.state.count}</div>
      <a href="http://baidu.com" onClick={this.add}>百度一下</a>
      <button onClick={this.add} onMouseEnter={this.mouseFn}>+1</button>
    </div>
  }
  add(e) {
    console.log('123');
    e.preventDefault(); //阻止事件
    e.stopPropagation();//阻止冒泡
  }
  mouseFn() {
    console.log('456');
  }
}

ReactDOM.render(<App></App>, document.getElementById('root'))